﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Web;
using System.Web.UI;

namespace Srs.Sample.UI
{
    public static class Extensions
    {
        public static string TimestampToString(this System.Data.Linq.Binary binary)
        {
            return Convert.ToBase64String(binary.ToArray());
        }


        public static System.Data.Linq.Binary StringToTimestamp(this string s)
        {
            return Convert.FromBase64String(s);
        }


        static TraceSwitch srsUiTraceSwitch = new TraceSwitch("Srs.UI.Tracing", "Tracing flag for SRS UI Tier");

        public static void LogException(this Control control, Exception ex)
        {
            HttpContext ctx = HttpContext.Current;
            ctx.Trace.Warn(ex.ToString());

            //TODO: Provide core.common service to format, send to sink, etc.
            System.Diagnostics.Trace.WriteLineIf(
                srsUiTraceSwitch.TraceError,
                ex.Message);
        }


    }
}
